function get_socket(url = "ws://localhost:8765") {
    var ws = new WebSocket(url); 
    ws.onopen =() => {
      //当WebSocket创建成功时，触发onopen事件
      console.log("open");
    }

    ws.onmessage = (e) => {
      //当收到消息时，触发onmessage事件
      console.log(e.data);
    }

    ws.onclose = () => {
      //当连接关闭时，触发onclose事件
      console.log("close");
    }

    ws.onerror = () => {
        //当发生错误时，触发onerror事件
        console.log("error");
    }

    return ws;
}